package org.example.erp.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.erp.domain.Inventory;
import org.example.erp.domain.WmIssueLine;
import org.example.erp.service.InventoryService;
import org.example.erp.service.WmIssueHeaderService;
import org.example.erp.service.WmIssueLineService;
import org.example.erp.mapper.WmIssueLineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
* @author dell
* @description 针对表【wm_issue_line(生产领料单行表)】的数据库操作Service实现
* @createDate 2024-12-11 19:39:28
*/
@Service
public class WmIssueLineServiceImpl extends ServiceImpl<WmIssueLineMapper, WmIssueLine>
    implements WmIssueLineService{

    @Autowired
    private WmIssueLineMapper wmIssueLineMapper;//领料单从表

    @Autowired
    private WmIssueHeaderService wmIssueHeaderService;//领料单主表

    @Autowired
    private InventoryService inventoryService;//库存

    public Page<WmIssueLine> selectWmIssueLineById(Page<WmIssueLine> page, Integer lineId){
        return wmIssueLineMapper.selectWmIssueLineById(page,lineId);
    }

    @Override
    public Integer updateWmIssueLineById(Inventory lineId) {
        Integer i = wmIssueLineMapper.updateWmIssueLineById(lineId);
        if(i > 0){//如果更新成功
                    boolean save = inventoryService.save(lineId);//保存(添加)库存
                    if(!save){//如果保存失败
                        return 0;//返回更新行数
                    }
        }
        return i;//返回更新行数
    }

}




